import AccsoaAction from "../functions/AccsoaAction";

export function onTableAfterEdit(props, moduleId, key, value, changedrows, record, index) {
  if(key == 'pk_assoa_in' || key == 'pk_assoa_out'){
    AccsoaAction.call(props, key,value,moduleId,index);
  }
}

/**
* 模态框取消按钮事件
* @param {*} props
*/
export function onCloseTableModel(props) {
}

export function onTableBeforeEdit(props, moduleId, item, index, value, record) {
  let meta = props.meta.getMeta();
  if (item.attrcode == 'pk_assoa_in' || item.attrcode == 'pk_assoa_out') {
    let assoaItem = meta['head']['items'].find(i => i.attrcode === item.attrcode);
    if(item.attrcode == 'pk_assoa_in'){
      assoaItem.queryCondition = () => {
        return {
          pk_accountingbook: this.state.inbook
        }
      }
    }else{
      assoaItem.queryCondition = () => {
        return {
          pk_accountingbook: this.state.outbook
        }
      }  
    }
    return true;
  }
  return true;
}